<include file="Shop:Sp_header" />
<include file="Shop:Sp_left" />
				<div class="joinin-concrete">
					<!-- 公司信息 -->

					<div id="apply_company_info" class="apply-company-info">
						<div class="alert">
							<h4>注意事项：</h4> 以下所需要上传的电子版资质文件仅支持JPG\GIF\PNG格式图片，大小请控制在1M之内。
						</div>
						<form id="form_company_info" action="/store_joinin/c2c_step2" method="post" enctype="multipart/form-data">
							<input name="sphash" type="hidden" id="sphash" value="">
							<table border="0" cellpadding="0" cellspacing="0" class="all">
								<thead>
									<tr>
										<th colspan="2">店铺及联系人信息</th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<th><i>*</i>企业名称：</th>
										<td><input name="shop_name" type="text" class="w200">
											<span></span></td>
									</tr>
									<tr>
										<th><i>*</i>所在地：</th>
										<td id="select">
											<input id="shop_address" name="shop_address" type="hidden" value="">
											
										</td>
									</tr>
									<tr>
										<th><i>*</i>详细地址：</th>
										<td><input name="shop_address_detail" type="text" class="w200">
											<span></span></td>
									</tr>
									<tr>
										<th><i>*</i>联系人姓名：</th>
										<td><input name="link_name" type="text" class="w100">
											<span></span></td>
									</tr>
									<tr>
										<th><i>*</i>联系人电话：</th>
										<td><input name="link_phone" type="text" class="w100">
											<span></span></td>
									</tr>
									<tr>
										<th><i>*</i>电子邮箱：</th>
										<td><input name="link_email" type="text" class="w200">
											<span></span></td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td colspan="20">&nbsp;</td>
									</tr>
								</tfoot>
							</table>
							<table border="0" cellpadding="0" cellspacing="0" class="all">
								<thead>
									<tr>
										<th colspan="20">企业信息</th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<th><i>*</i>公司名称：</th>
										<td><input name="one_sphere" type="text" class="w300">
											<span></span></td>
									</tr>
									<tr>
										<th><i>*</i>企业营业执照编号：</th>
										<td><input name="one_licence_number" type="text" class="w300">
											<span></span></td>
									</tr>
									<tr>
										<th><i>*</i>营业执照扫描件：</th>
										<td><input name="pic" type="file" class="w200">
											<!-- <img border="0" alt="营业执照扫描件" src="__PUBLIC__/Home/images/example.jpg" style="width:300px;height:210px"> -->
											<span class="block">请确保图片清晰，营业执照编号文字可辨（清晰照片也可使用）。</span></td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td colspan="20">&nbsp;</td>
									</tr>
								</tfoot>
							</table>
						</form>
						<div class="bottom">
							<a id="btn_apply_company_next" href="javascript:;" class="btn">下一步，提交财务资质信息</a>
						</div>
					</div>
				</div>
			</div>
		</div>
<include file="Shop:Sp_footer" />
<script>
var shop_address = $("#shop_address").val();
var se_tml = '';
if (shop_address) {
	se_tml = '<span id="_area_span" class="_region_value"> '+shop_address+'</span><input type="button" class="input-btn" id="chenge" value="编辑">';
	$("#shop_address").after(se_tml);
} else {
	se_tml = '<select name="shop_province" id="shop_province"><option value="">-请选择-</option><volist name="code" id="vo"><option value="{$vo.area_name}" data-id="{$vo.area_id}">{$vo.area_name}</option></volist></select>';
	$("#shop_address").after(se_tml);
}

$("#chenge").live('click',function(){
	se_tml = '<select name="shop_province" id="shop_province"><option value="">-请选择-</option><volist name="code" id="vo"><option value="{$vo.area_name}" data-id="{$vo.area_id}">{$vo.area_name}</option></volist></select>';
	$("#_area_span").hide();
	$("#chenge").hide();
	$("#shop_address").after(se_tml);	
});

	$("select").live('change',function(){
		var option = $(this).val();
		var data_id = $(this).find("option[value='"+option+"']").attr("data-id");
		var next = $(this).next("select").html();         
		var id = $(this).attr('id');
		var name ='city';
		var length = $("select").length;		
		var next_p = '';

		var province = $('#shop_province').val();
		var city = $('#shop_city').val();
		var area = $('#shop_area').val();
		var address = '';	
		
		if (province) {
			address = province;
		}
		if (city==option) {
			address = address +' '+ city;
		} 
		
		if (area==option) {
			address = address +' '+ city +' '+ area;
		}
		
		$('#shop_address').val(address);		
		
		if (option) {
			if (next) {
				
				if (length<3) {
					name ='shop_city';
				} else {
					if (id=='shop_province') {						
						name ='shop_city';
						next_p = 1;
					} else {
						name ='shop_area';
					}					
				}
			} else {
				if (length<2) {
					name ='shop_city';					
				} else {
					name ='shop_area';
				}			
			}

			if (id!=='shop_area') {
				get_area(data_id,next,$(this),name,next_p);	
			}						
		} else {			
			$(this).next("select").remove();
		}

	});

	//市级、区数据
	function get_area(id,next,option,name,next_p) {
		var url='/Shop/code_chage';		
		$.ajax({
			url:url,
			data:{id:id},
			type:'post',
			dataType:'json',
			success:function (data) {
				var a = data;
				var html = '';
				for(var i=0;i<a.length;i++ ) {								
					html += '<option value ="'+a[i].area_name+'" data-id="'+a[i].area_id+'">'+a[i].area_name+'</option>';
				}
				
				if (html) {
					if (next) {	
						if (next_p) {
							option.nextAll("select").html('<option value="">-请选择-</option>'+html);
							option.next().nextAll("select").remove();
						} else {
							option.next("select").html('<option value="">-请选择-</option>'+html);
						}
						
					} else {
						option.after('<select name="'+name+'" id="'+name+'"><option value="">-请选择-</option>'+html+'</select>');
					}				
				}
				
			}
		});		
	}
				// 获取长度为len的随机字符串  
				function _getRandomString(len) {  
					len = len || 32;  
					var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678910'; // 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1  
					var maxPos = $chars.length;  
					var pwd = '';  
					for (i = 0; i < len; i++) {  
						pwd += $chars.charAt(Math.floor(Math.random() * maxPos));  
					}  
					return pwd;  
				} 

</script>

<script type="text/javascript">
$(document).ready(function(){



    $('#form_company_info').validate({
        errorPlacement: function(error, element){
            element.nextAll('span').first().after(error);
        },
        rules : {
            shop_name: {
                required: true,
                maxlength: 50 
            },
            shop_address: {
                required: true,
                maxlength: 50 
            },
            shop_address_detail: {
                required: true,
                maxlength: 50 
            },
            link_name: {
                required: true,
                maxlength: 20 
            },
            link_phone: {
                required: true,
                maxlength: 20 
            },
            link_email: {
                required: true,
                email: true 
            },
            one_sphere: {
                required: true,
                maxlength: 20
            },
            one_licence_number: {
                required: true,
                maxlength: 500
            },
            pic: {
                required: true
            },
        },
        messages : {
            shop_name: {
                required: '请输入店铺名字',
                maxlength: jQuery.validator.format("最多{0}个字")
            },
            shop_address: {
                required: '请选择区域地址',
                maxlength: jQuery.validator.format("最多{0}个字")
            },
            shop_address_detail: {
                required: '请输入目前详细住址或办公地址',
                maxlength: jQuery.validator.format("最多{0}个字")
            },
            link_name: {
                required: '请输入联系人姓名',
                maxlength: jQuery.validator.format("最多{0}个字")
            },
            link_phone: {
                required: '请输入联系人电话',
                maxlength: jQuery.validator.format("最多{0}个字")
            },
            link_email: {
                required: '请输入常用邮箱地址',
                email: '请填写正确的邮箱地址'
            },
            one_sphere: {
                required: '请输入身份证号',
                maxlength: jQuery.validator.format("最多{0}个字")
            },
            one_licence_number: {
                required: '请填写身份证上姓名',
                maxlength: jQuery.validator.format("最多{0}个字")
            },
            pic: {
                required: '请选择上传手执身份证照'
            },
        }
    });

    $('#btn_apply_company_next').on('click', function() {
        if($('#form_company_info').valid()) {
			$("#sphash").val(_getRandomString(29));
            $('#form_company_info').submit();
        }
    });
});
</script>
<script type="text/javascript">
	$(document).ready(function() {
		$('#btn_apply_company_next').on('click', function() {
			
		//alert(11);
			$("#form_company_info").submit();
			//window.location.href = "/store_joinin/c2c_step2";
		});
	});

</script>

	</body>

</html>